import request from "./request"

export function create(staffInfo){
  return request({
    url:"/staff/create",
    method:"post",
    data:staffInfo
  }) 
}

export function getList(currentPage,limit,role=null){
  return request({
    url:"/staff/find_on_condition",
    method:"get",
    params:{
      currentPage,
      limit,
      role
    }
  })
}

export function findByName(name){
  return request({
    url:"/staff/name",
    method:"get",
    params:{
      name
    }
  })
}

export function findByRole(role){
  return request({
    url:"/staff/role",
    method:"get",
    params:{
      role
    }
  })
}

export function deleteById(id){
  return request({
    url:"/staff/delete_by_id",
    method:'post',
    data:{
      id
    }
  })
}

export function update(staffInfo){
  return request({
    url:"/staff/update_by_id",
    method:"post",
    data:staffInfo
  })
}

export function login(loginInfo){
  return request({
    url:"/staff/login",
    method:"post",
    data:loginInfo
  })
}

export function logout(staffId){
  return request(
    {
      url:"/staff/logout",
      method:"post",
      data:{
        staffId
      }
    }
  )
}